//
//  Person.m
//  OC05-HomeWork!(周六)
//
//  Created by dllo on 16/7/8.
//  Copyright © 2016年 高雅馨. All rights reserved.
//

#import "Person.h"

@implementation Person
-(instancetype)initWithName:(NSString *)name Age:(int)age Sex:(NSString *)sex {
    self = [super init];
    if (self) {
        _name = name;
        _age = age;
        _sex = sex;
    }return self;
}
+(instancetype)nurseWithName:(NSString *)name Age:(int)age Sex:(NSString *)sex {
    return [[Person alloc] initWithName:name Age:age Sex:sex];
}
-(NSComparisonResult)sortByAge:(Person *)person {
    if (self.age < person.age) {
        return NSOrderedAscending;
    }else if (self.age == person.age){
        return NSOrderedSame;
    }else{
        return NSOrderedDescending;
    }
}
-(NSComparisonResult)sortByName:(Person *)person {
    return [self.name compare:person.name];
}
-(NSComparisonResult)sortBySex:(Person *)person {
    return [self.sex compare:person.sex];
}
@end
